From: Jimi Xenidis Date: Thu, 14 Sep 2006 15:11:00 +0000 (-0400) Subject: [POWERPC][XEN] add ofd_strstr() that checks all strings from an OF property X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~15658^2~62 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success//%22http:/www.example.com/cgi/success/?a=commitdiff_plain;h=2a001466a9060909f50c6ef8ef5848fd2df9b8e3;p=xen.git [POWERPC][XEN] add ofd_strstr() that checks all strings from an OF property Some OF properties can have a list of '\0' terminated strings, we frequently need to strstr against all of them. Signed-off-by: Jimi Xenidis Signed-off-by: Hollis Blanchard --- diff --git a/xen/arch/powerpc/dart.c b/xen/arch/powerpc/dart.c index 0de55a58d7..fef8efa322 100644 --- a/xen/arch/powerpc/dart.c +++ b/xen/arch/powerpc/dart.c @@ -207,16 +207,17 @@ static int find_dart(struct dart_info *di) if (rc <= 0) return -1; - di->di_base = DART_DEF_BASE; - - if (strstr(compat, "u3")) { - di->di_model = DART_U3; - } else if (strstr(compat, "u4")) { + if (ofd_strstr(compat, rc, "u4")) di->di_model = DART_U4; - } else { + else if (ofd_strstr(compat, rc, "u3")) + di->di_model = DART_U3; + else { DBG("%s: not a U3 or U4\n", __func__); return -1; } + + di->di_base = DART_DEF_BASE; + /* FIXME: this should actually be the HT reg value */ di->di_window.dw_liobn = 0; di->di_window.dw_base_hi = 0; diff --git a/xen/arch/powerpc/of-devtree.h b/xen/arch/powerpc/of-devtree.h index 3b0439c23c..21e96ef911 100644 --- a/xen/arch/powerpc/of-devtree.h +++ b/xen/arch/powerpc/of-devtree.h @@ -136,4 +136,20 @@ extern ofdn_t ofd_node_find_next(void *mem, ofdn_t n); extern ofdn_t ofd_node_find_prev(void *mem, ofdn_t n); extern void ofd_init(int (*write)(const char *, size_t len)); +static inline int ofd_strstr(const char *s, int len, const char *str) +{ + int l = strlen(str); + do { + int n; + + if (len >= l && strstr(s, str)) + return 1; + + n = strnlen(s, len) + 1; + len -= strnlen(s, len) + 1; + s += n; + } while (len > 0); + return 0; +} + #endif /* _OF_DEVTREE_H */